﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System.Collections.ObjectModel;

namespace TotalApplication.Core
{
    public partial class ChatListItemViewModel : BaseViewModel
    {
        #region Public properties
        [ObservableProperty]
        private string? _name;

        [ObservableProperty]
        private string? _message;

        [ObservableProperty]
        private string? _initial;

        /// <summary>
        /// The RGB values for the background color of the profile picture.
        /// </summary>
        [ObservableProperty]
        private string? _profilePictureRGB;

        [ObservableProperty]
        private bool _newContentAvailable;

        [ObservableProperty]
        private bool _isSelected;
        #endregion

        #region Commands

        [RelayCommand]
        private void OpenMessage()
        {
            IoC.Application.GoToPage(ApplicationPage.Chat, new ChatMessageListViewModel
            {
                Items = new ObservableCollection<ChatMessageListItemViewModel>
                {
                    new ChatMessageListItemViewModel
                    {
                        Message = Message,
                        Initial = "T",
                        ProfilePictureRGB = "3099c7",
                        SenderName = "Tian_ZJ",
                        SentByMe = true,
                        MessageReadTime = DateTime.UtcNow,
                    },
                    new ChatMessageListItemViewModel
                    {
                        Message = "Hey! This is a reply from TZJlll",
                        Initial = "T",
                        ProfilePictureRGB = "f68d1e",
                        SenderName = "TZJlll",
                        SentByMe = false,
                        MessageReadTime = DateTime.UtcNow,
                    },
                    new ChatMessageListItemViewModel
                    {
                        Message = "This is another message from Tian_ZJ",
                        Initial = "T",
                        ProfilePictureRGB = "f68d1e",
                        SenderName = "Tian_ZJ",
                        SentByMe = true,
                        MessageReadTime = DateTime.UtcNow,
                    },
                    new ChatMessageListItemViewModel
                    {
                        SenderName = "Parnell",
                        Message = $"OSVersion: 【{Environment.OSVersion}】\r\nProcessorCount: 【{Environment.ProcessorCount}】\r\nUserDomainName: 【{Environment.UserDomainName}】\r\nThe new server is upo. Go to 192.168.1.1 Username is admin, password is P8ssawovd",
                        Initial = "PL",
                        ProfilePictureRGB = "3099c5",
                        MessageSentTime = DateTimeOffset.UtcNow,
                        SentByMe = false,
                        ImageAttachment = new ChatMessageListImageItemViewModel{ThumbnailUrl="/assets/img/example.png"}
                    },
                },
            });
        }

        #endregion

    }
}
